//Accepted
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <iostream>
#include <list>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;

int a[2], n, t, i;
int gcd(int a, int b){
	while(b){
		t=b;
		b=a%b;
		a=t;
	}
	return a;
}
int main (){
	//freopen("in.txt", "r", stdin);//freopen("out.txt", "w", stdout);
	scanf("%d%d%d", &a[0], &a[1], &n);
	i=0;
	while(n>=0){
		if(a[i]>n)n -= gcd( a[i],n );
		else n -= gcd( n, a[i] );
		i=(i+1)%2;
	}
	printf("%d", i);
	return 0;
}
